package ysc.cqnu.operdb.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ysc.cqnu.operdb.entity.Engrave;
import ysc.cqnu.operdb.entity.ResultData;
import ysc.cqnu.operdb.mapper.DiaoKeMapper;
import ysc.cqnu.operdb.service.CheckDiaoKeInfoService;

@Service
public class CheckDiaoKeInfoServiceImpl implements CheckDiaoKeInfoService {
    @Autowired
    private Engrave engrave;
    @Autowired
    private ResultData resultData;
    @Autowired
    private DiaoKeMapper diaoKeMapper;
    @Override
    public ResultData checkDiaoKeInfoService(String diaokename, String renwu, String yongtu, String juti, String uploader, String uploadDate) {
        try {
            engrave = diaoKeMapper.chazhaoDiaoKeInfo(diaokename,renwu,yongtu,juti,uploader,uploadDate);

            if(engrave!=null){
                int count = diaoKeMapper.count();
                int site = diaoKeMapper.diaokeInfoSite(String.valueOf(engrave.getId()));
                engrave.Count=String.valueOf(count);
                engrave.site=String.valueOf(site);
                resultData.flag="CheckSuccess";
                resultData.data=engrave;
                return resultData;
            }
            else {
                resultData.flag="DiaoKeInfoNoFind";
                resultData.data=null;
                return resultData;
            }
        }catch (Exception e){
            resultData.flag="CheckFail";
            resultData.data=null;
            return resultData;
        }
    }
}
